package com.ndp.fb.mq.service.schedulerservice.adpublish;

import com.alibaba.dubbo.config.annotation.Reference;
import com.alibaba.dubbo.config.annotation.Service;
import com.ndp.ec.core.api.DPAAdPerformService;
import com.ndp.fb.mq.api.service.schedulerservice.AdPublishSchedulerService;
import com.ndp.fb.mq.service.schedulerservice.business.FetchCustomaudiencesService;
import com.ndp.fb.mq.service.schedulerservice.thirdpictureaudit.AdGroupAuditForThirdPicService;
import com.ndp.fb.mq.service.schedulerservice.thirdpictureaudit.AutoCheckRecourceOneStep;
import com.ndp.fb.rdb.model.PublishBatch;
import com.ndp.fb.util.ThreadPool;
import org.springframework.beans.factory.annotation.Autowired;

/**
 * Created by Evan on 2015/3/4 16:52.
 */
@Service
public class AdPublishSchedulerServiceImpl implements AdPublishSchedulerService {
    @Autowired
    private PublishAdCampCountAndAdSetCountService publishAdCampCountAndAdSetCountService;

    @Autowired
    private FetchCustomaudiencesService fetchCustomaudiencesService;

    @Autowired
    private PrePublishProcessScanService prePublishProcessScanService;

    @Autowired
    private PublishAdGroupStatusScanService publishAdGroupStatusScanService;

    @Autowired
    private PublishAdCreativeStatusScanService publishAdCreativeStatusScanService;

    @Autowired
    private PublishAdCreativeService publishAdCreativeService;

    @Autowired
    private AutoCheckRecourceOneStep autoCheckRecourceOneStep;

    @Autowired
    private AdGroupAuditForThirdPicService adGroupAuditForThirdPicService;

    @Autowired
    private FetchFbUsersService fetchFbUsersService;
    @Reference
    DPAAdPerformService dPAAdPerformService;

    @Override
    public void fetchAdCampCountAndAdSetCount(Long accountId) {
        publishAdCampCountAndAdSetCountService.fetchAdCampCountAndAdSetCount(accountId);
    }

    @Override
    public void publishAdCreativeStatusScan(PublishBatch batch) {
        ThreadPool.execute(() ->publishAdCreativeStatusScanService.execute(batch));
    }

    @Override
    public void fetchCustomaudiences(Long accountId) {
        fetchCustomaudiencesService.fetchCustomaudiences(accountId);
    }

    @Override
    public void prePublishProcessScan(Long batchId) {
        ThreadPool.execute(() -> prePublishProcessScanService.execute(batchId));
    }

    @Override
    public void publishAdGroupStatusScan() {
        publishAdGroupStatusScanService.execute();
    }

    @Override
    public void publishAdCreativeScan(Long batchId) {
        publishAdCreativeService.publish(batchId,null,null);
    }


    @Override
    public void autoPublishForThirdpic() {
        autoCheckRecourceOneStep.autoPublishAdCampaign();
    }

    @Override
    public void autoAuditAd() {
        adGroupAuditForThirdPicService.auditAdFix();
    }

    @Override
    public void fetchFbUsers() {
        fetchFbUsersService.fetchFbUsers();
    }

	@Override
	public void prePublishAdMarketTargetScan() {
		 dPAAdPerformService.publishAdMarketTarget();
	}
}
